<?php 

/**
 * 类型属性控制器
 */
class TypeAttrController extends Controller{
	private $model;
	
	public function __init(){
		$this->model = K('TypeAttr');
	}
	
    /**
     *  首页
     */
    public function index(){
    		$tid = Q('get.tid', 0, 'intval');
    		$data = $this->model->where("tid={$tid}")->all();
		$this->assign('data', $data);
		$this->display(); 
    }
	
	// 添加
	public function add(){
		if (IS_POST){
			if (!$this->model->addData()){
				$this->error($this->model->error);
			}
			$this->success('添加类型属性成功', U('Index', array('tid'=>$_GET['tid'])));
		}
	    $this->display();
	}
	
	// 修改
	public function edit(){
		if (IS_POST){
			if (!$this->model->editData()){
				$this->error($this->model->error);
			}
			$this->success('修改类型属性成功', U('Index', array('tid'=>$_GET['tid'])));		
		}
		$taid = Q('get.taid', 0, 'intval');
		$this->assign('oldData', $this->model->where("taid={$taid}")->find());
	    $this->display();
	}
	
	// 删除
	public function del(){
	    $taid = Q('get.taid', 0, 'intval');
		if (!$this->model->where("taid={$taid}")->delete()){
			$this->error($this->model->error);
		}
		$this->success('删除类型属性成功', U('Index', array('tid'=>$_GET['tid'])));		
	}
 }
 
 
 
 
 
 
 
 
 
 
 

 ?>